package com.huirui.server.pojo.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 商品参数信息VO对象，包含商品的生产、注册等详细参数
 */
@Data
@Schema(
        name = "ProductParameterVo",
        description = "商品参数详情VO，用于返回商品生产企业、注册证号、有效期等核心参数信息",
        example = "{\n" +
                "  \"productId\": 1001,\n" +
                "  \"manufacturingEnterprise\": \"XX医疗器械有限公司\",\n" +
                "  \"registrationNumber\": \"国械注准2023123456\",\n" +
                "  \"medicalInsuranceNumber\": \"YB2023654321\",\n" +
                "  \"registrationIdPhoto\": \"https://example.com/cert/2023123456.jpg\",\n" +
                "  \"productPackaging\": \"200ml/瓶，1瓶/盒\",\n" +
                "  \"manufacturingDate\": \"2023-06-15\",\n" +
                "  \"expiryDate\": \"2025-06-14\",\n" +
                "  \"createTime\": \"2023-06-16T10:30:00\",\n" +
                "  \"updateTime\": \"2023-06-16T10:30:00\"\n" +
                "}"
)
public class ProductParameterVo implements Serializable {

    @Schema(
            description = "商品ID（关联商品主表）",
            example = "1001",
            requiredMode = Schema.RequiredMode.REQUIRED, // 标记为必填字段
            type = "integer",
            format = "int64"
    )
    private Long productId;

    @Schema(
            description = "生产企业名称",
            example = "XX医疗器械有限公司",
            requiredMode = Schema.RequiredMode.REQUIRED,
            maxLength = 255 // 限制字段长度，符合数据库设计
    )
    private String manufacturingEnterprise;

    @Schema(
            description = "产品注册证编号（如：国械注准/械注准）",
            example = "国械注准2023123456",
            requiredMode = Schema.RequiredMode.REQUIRED,
            maxLength = 50,
            pattern = "^(国械注准|械注准|京械注准|沪械注准)\\d{8,10}$" // 正则校验格式（可选）
    )
    private String registrationNumber;

    @Schema(
            description = "医保编号（无医保则返回空）",
            example = "YB2023654321",
            requiredMode = Schema.RequiredMode.NOT_REQUIRED,
            maxLength = 50,
            nullable = true // 标记为可空
    )
    private String medicalInsuranceNumber;

    @Schema(
            description = "注册证照片URL（支持HTTP/HTTPS）",
            example = "https://example.com/cert/2023123456.jpg",
            requiredMode = Schema.RequiredMode.NOT_REQUIRED,
            maxLength = 512,
            nullable = true,
            format = "uri" // 标记为URL格式
    )
    private String registrationIdPhoto;

    @Schema(
            description = "商品包装规格（如：容量/数量/包装材质）",
            example = "200ml/瓶，1瓶/盒",
            requiredMode = Schema.RequiredMode.REQUIRED,
            maxLength = 255
    )
    private String productPackaging;

    @Schema(
            description = "生产日期（格式：yyyy-MM-dd）",
            example = "2023-06-15",
            requiredMode = Schema.RequiredMode.REQUIRED,
            type = "string",
            format = "date" // 标记为日期格式（仅日期，无时间）
    )
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") // 序列化格式统一
    private LocalDate manufacturingDate;

    @Schema(
            description = "有效期至（格式：yyyy-MM-dd）",
            example = "2025-06-14",
            requiredMode = Schema.RequiredMode.REQUIRED,
            type = "string",
            format = "date"
    )
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDate expiryDate;

    @Schema(
            description = "参数创建时间（自动填充）",
            example = "2023-06-16T10:30:00",
            requiredMode = Schema.RequiredMode.REQUIRED,
            type = "string",
            format = "date-time" // 标记为日期时间格式
    )
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;

    @Schema(
            description = "参数更新时间（自动填充）",
            example = "2023-06-16T10:30:00",
            requiredMode = Schema.RequiredMode.REQUIRED,
            type = "string",
            format = "date-time"
    )
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;

    @Serial
    private static final long serialVersionUID = 1L;
}